<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org/">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <div th:replace="header::common"></div>
</head>
<body>
    <!--<button class="btn">点击</button>
    <button class="btn btn-success">点击</button>
    <button class="btn btn-danger">点击</button>-->

    <a class="btn btn-sm btn-primary" href="/dept/toAdd">添加</a>
    <table class="table table-bordered table-hover table-condensed">
        <tr>
            <td>ID</td>
            <td>部门名</td>
            <td>删除</td>
            <td>编辑</td>
        </tr>
        <tr th:each="dept:${list}">
            <td th:text="${dept.id}">1</td>
            <td th:text="${dept.name}">zhangsan</td>
            <td><a class="btn btn-xs btn-danger" th:onclick="|deleteById(${dept.id})|">删除</a></td>
            <td><a class="btn btn-xs btn-primary" th:href="|/dept/toUpdate?id=${dept.id}|">编辑</a></td>
        </tr>
    </table>

    <script>
        function deleteById(id) {
            //弹出一个确认框来
            layer.confirm('您确认要删除么？', function() {
                location.href = '/dept/deleteById?id=' + id;
            })
        }
    </script>
</body>
</html>